package org.jeecg.modules.base.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.jeecg.modules.base.entity.BaseStudent;
import org.jeecg.modules.base.entity.vo.StudentVo;
import org.jeecg.modules.base.mapper.BaseStudentMapper;
import org.jeecg.modules.base.service.IBaseScoreService;
import org.jeecg.modules.base.service.IBaseStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

/**
 * @Description: base_student
 * @Author: jeecg-boot
 * @Date: 2021-04-14
 * @Version: V1.0
 */
@Service
public class BaseStudentServiceImpl extends ServiceImpl<BaseStudentMapper, BaseStudent> implements IBaseStudentService {

    @Autowired
    private IBaseScoreService baseScoreService;

    @Override
    public List<StudentVo> getList(BaseStudent baseStudent) {
        List<StudentVo> vos = baseMapper.getList(baseStudent);
        for (StudentVo vo : vos) {
            Integer score = baseScoreService.getSum(vo.getId());
            if (score != null) {
                vo.setScore(score);
            } else {
                vo.setScore(0);
            }
        }
        return vos;
    }
}
